# Create your models here.


from django.db import models

from apps.gupiaoliebiao.models import gupiaoliebiao
from utils.models import CoreModel


class huicefenxi(CoreModel):
    name = models.CharField(max_length=250, verbose_name='分析名', null=True, blank=True)
    gongshi = models.CharField(max_length=100, verbose_name="公式", null=True, blank=True)
    jisuanzhouqi = models.CharField(max_length=100, verbose_name="计算周期", null=True, blank=True)
    fuquan = models.CharField(max_length=100, verbose_name="复权", null=True, blank=True)
    pingceshijianduankaishi = models.CharField(max_length=100, verbose_name="评测时间段-开始", null=True, blank=True)
    pingceshijianduanjieshu = models.CharField(max_length=100, verbose_name="评测时间段-结束", null=True, blank=True)
    danpinzhongchushifenpeizijin = models.CharField(max_length=100, verbose_name="单品种初始分配资金", null=True,
                                                    blank=True)
    zuidasunshizhisun = models.CharField(max_length=100, verbose_name="最大损失止损", null=True, blank=True)
    zuidashouyizhiying = models.CharField(max_length=100, verbose_name="最大收益止赢", null=True, blank=True)

    class Meta:
        app_label = 'huicefenxi'
        db_table = 'tb_huicefenxi'
        verbose_name = "回测分析"
        verbose_name_plural = verbose_name


class huicefenxi_data(CoreModel):
    gupiaoliebiao_id = models.ForeignKey(gupiaoliebiao, on_delete=models.CASCADE, null=True, blank=True)
    huicefenxi_id = models.ForeignKey(huicefenxi, on_delete=models.CASCADE)
    pingzhongdaima = models.CharField(max_length=100, verbose_name="品种代码", null=True, blank=True)
    pingzhongmingchen = models.CharField(max_length=100, verbose_name="品种名称", null=True, blank=True)
    yinglishu = models.CharField(max_length=100, verbose_name="盈利数", null=True, blank=True)  # windows、centos、小写
    zongcishu = models.CharField(max_length=100, verbose_name="总次数")
    shenglv = models.CharField(max_length=100, verbose_name="胜率(%)")  # True开启 False关闭
    shouxufei = models.CharField(max_length=100, verbose_name="手续费(元)")
    jinlirun = models.CharField(max_length=100, verbose_name="净利润(元)")
    shouyilv = models.CharField(max_length=100, verbose_name="收益率(%)")
    nianhuashouyilv = models.CharField(max_length=100, verbose_name="年化收益率(%)")
    xiangduishouyilv = models.CharField(max_length=100, verbose_name="相对收益率α/β(%)")
    zuidahuice = models.CharField(max_length=100, verbose_name="最大回撤(元)")
    zuidahuicebi = models.CharField(max_length=100, verbose_name="最大回撤比(%)")

    class Meta:
        app_label = 'huicefenxi'
        db_table = 'tb_huicefenxi_data'
        verbose_name = "回测分析数据"
        verbose_name_plural = verbose_name
